package main;

import device.BaseDevice;
import environment.data.BaseEnvironmentData;
import environment.object.BaseEnvironmentObject;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import device.IXmlConfig;
import xml.parser.DomParser;

public class Main {

    public static void main(String[] args)    {
        System.out.println("Some text "+System.currentTimeMillis());

        /*BaseEnvironmentObject room = new Room(1l,"First room");
        BaseEnvironmentData dataTemperature = new Temperature();
        room.addData(dataTemperature);*/

        FileSystemXmlApplicationContext ac = new FileSystemXmlApplicationContext(new String[] {"C:\\config.xml"});
        BaseEnvironmentObject room = (BaseEnvironmentObject) ac.getBean("room");
        BaseEnvironmentData dataTemperature = (BaseEnvironmentData) ac.getBean("temperature");//new Temperature();
        room.addData(dataTemperature);

        BaseDevice sensorTemperature = (BaseDevice)  ac.getBean("sensorTemperature");//new TemperatureDevice(1l,"Temperature device",room);
        BaseDevice conditioner = (BaseDevice)  ac.getBean("conditioner1"); //new Conditioner(2l,"1","Conditioner",room,10l);
        BaseDevice conditioner2 = (BaseDevice)  ac.getBean("conditioner2");//new Conditioner(3l,"2","Conditioner 2",room,5l);
        room.addSensor(sensorTemperature);

        DomParser domParser = new DomParser();
        domParser.initSensorFromXml((IXmlConfig)conditioner);
        domParser.initSensorFromXml((IXmlConfig)conditioner2);

        Thread myTread = new Thread(sensorTemperature);
        Thread myTread2 = new Thread(conditioner);
        Thread myTread3 = new Thread(conditioner2);

        myTread.start();
        myTread2.start();
        myTread3.start();



    }
}
